﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <h1>请输入xml字符串：</h1>
    <textarea id="xmlArea" rows="6" cols="200"><p>123</p></textarea>
    <input value="解析xml文档 " onclick="parserXML()" />
    <script type="text/javascript">

        function parserXML() {
            var strXML = document.getElementById("xmlArea").value;
            var xmlDom = new ActiveXObject("MSXML2.DOMDocument.6.0");
            xmlDom.loadXML(strXML);
            if (xmlDom.parseError != 0) {
                alert("解析错误");
            } else {
                alert(xmlDom.documentElement.tagName);
            }
        }

    </script>
</body>
</html>
